//
//  PhotoBrowserProgressView.swift
//  Status
//
//  Created by Kylin on 16/4/1.
//  Copyright © 2016年 Kylin. All rights reserved.
//

import UIKit

class PhotoBrowserProgressView: UIView {

    // MARK:- 自定义属性
    var progress : CGFloat = 0 {
        didSet {
            setNeedsDisplay()
        }
    }
   
    // MARK:- 重写drawRect方法
    override func drawRect(rect: CGRect) {
        super.drawRect(rect)
        
        // 画出进度的圈圈
        let center = CGPoint(x: rect.width * 0.5, y: rect.height * 0.5)
        let radius = rect.width * 0.5 - 8
        let startAngle = CGFloat(-M_PI_2)
        let endAngle = CGFloat(M_PI_2 * 2) * progress + startAngle
        
        let bezierPath = UIBezierPath(arcCenter: center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: true)
        
        bezierPath.addLineToPoint(center)
        bezierPath.closePath()
        
        UIColor(white: 0.9, alpha: 0.4).setFill()
        
        bezierPath.fill()
    }

}
